package com.itheima.原子性.Demo1;

import java.util.concurrent.atomic.AtomicInteger;

public class MyAtomThread implements Runnable {
    //private int count = 0;
    //public AtomicInteger​(int initialValue)   用给定的初始值创建一个新的AtomicInteger。
    AtomicInteger count = new AtomicInteger(0);
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            //synchronized ("lock") {
                count.getAndIncrement();
                System.out.println("已经送出的第"+count + "个冰淇淋");
            //}
        }
    }

    public int getCount(){
        return count.get();
    }
}
